<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%--
  Created by IntelliJ IDEA.
  User: PromiseT
  Date: 2022/5/26
  Time: 9:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <!-- 指定字符集 -->
    <meta charset="utf-8">
    <!-- 使用Edge最新的浏览器的渲染方式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- viewport视口：网页可以根据设置的宽度自动进行适配，在浏览器的内部虚拟一个容器，容器的宽度与设备的宽度相同。
    width: 默认宽度与设备的宽度相同
    initial-scale: 初始的缩放比，为1:1 -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.min.css">
    <script src="static/bootstrap/js/jquery-3.3.1.min.js"></script>
    <script src="static/bootstrap/js/bootstrap.js"></script>
    <style type="text/css">
        td, th {
            text-align: center;
        }
    </style>
</head>
<body>
<div style="width: 1250px;">
    <form action="/StudentServlet/findByCase" method="post">
<%--        <input name="aa" type="text" placeholder="aa">--%>
        <tr>
            <td style="vertical-align: middle">

                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input type="text" id="user" size="10" name="sname" value="${stu.name}" placeholder="姓名">
            </td>
            <td style="vertical-align: middle">
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <select style="height: 30px;" name="smale" id="male">
                    <option>请选择</option>
                    <option ${stu.male=='男'?"selected":''}>
                        男
                    </option>
                    <option ${stu.male=='女'?"selected":''}>
                        女
                    </option>
                </select>
            </td>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <td  width="40" style="vertical-align: middle">
<%--                <a  class="btn btn-primary ">--%>
<%--                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--%>
<%--                    查询--%>
<%--                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--%>
<%--                </a>--%>
                <button class="btn btn-default" type="submit">查找</button>
                <a class="btn btn-default" href="/StudentServlet/back" role="button">返回</a>
            </td>
        </tr>
    </form>

<%--<form action="/StudentServlet/findAll" method="post">--%>
        <table border=1 class="table table-striped table-bordered">
            <tr >
                <th>学号</th>
                <th>姓名</th>
                <th>性别</th>
                <th>年龄</th>
                <th>年级</th>
                <th>状态</th>
            </tr>
            <c:forEach var="s" items="${list}">
                <tr>
                    <td>${s.stuID}</td>
                    <td>${s.name}</td>
                    <td>${s.male}</td>
                    <td>${s.age}</td>
                    <td>${s.grade}</td>
                    <td>${s.state}</td>
                    <td>
                        <a class="btn btn-default btn-sm" href="/StudentServlet/findOne?stuID=${s.stuID}">修改</a>&nbsp;
                        <a class="btn btn-default btn-sm" href="/StudentServlet/delete?stuID=${s.stuID}">删除</a>
                    </td>
                </tr>
            </c:forEach>
<%--</form>--%>
            <tr>
                <td colspan="8" align="center">
                    <a href="/StudentServlet/findPages?pageNo=1" class="btn btn-primary" id="first">首页</a>
                    &nbsp; &nbsp;
<%--                    <a href="#"  id="prev" class="btn btn-primary" >上一页</a>--%>
                    <c:forEach var="i" begin="1" end="${total}">
                        <a href="/StudentServlet/findPages?pageNo=${i}" onclick="goto(${i})">${i}</a>
                    </c:forEach>

<%--                    <a href="#" id="next" class="btn btn-primary">下一页</a>--%>
                    &nbsp; &nbsp;
                    <a href="/StudentServlet/findPages?pageNo=${total}" class="btn btn-primary" id="last">尾页</a>
                </td>
            </tr>
        </table>
</div>
</body>
</html>
<script>
    function goto(param) {
        location.href="/StudentServlet/findPages?pageNo="+param;
    }
    $("#prev").click(function () {
        //获取当前页码-1
        var pageNo = ${param.pageNo};
        pageNo--;
        if (pageNo<1){
            pageNo=1;
        }
        location.href="/StudentServlet/findPages?pageNo="+pageNo;

    })
    $("#next").click(function () {
        var pageNo = ${param.pageNo};
        pageNo++;
        if (pageNo>${total}){
            pageNo=${total};
        }
        location.href="/StudentServlet/findPages?pageNo="+pageNo;
    })
   /* $("#find").click(function () {
        var sname = $("#user").val();
        var smale = $("#male").val();
        alert(name);
        location.href="/StudentServlet/findByCase?sname="+sname+"&smale="+smale+"&pageNo=1";
    })*/
    $("#find").click(function () {
        var sname = $("#user").val();
        var smale = $("#male").val();
        alert(sname);
    })

</script>